package uk.co.cocking.getinline2.pipeline.transformers;

import java.util.ArrayList;
import java.util.List;

import uk.co.cocking.getinline2.exceptions.EnvironmentException;
import uk.co.cocking.getinline2.pipeline.io.CouldNotProcessRecordException;

public abstract class AbstractTransformer<IncomingType, OutgoingType>
	 implements Transformer<IncomingType, OutgoingType> {

	@Override
	public List<OutgoingType> close() throws EnvironmentException {
		return emptyList();
	}

	@Override
	public List<OutgoingType> open() throws EnvironmentException {
		return emptyList();
	}

	@Override
	public abstract List<OutgoingType> transform(IncomingType incomingItem)
			throws CouldNotProcessRecordException;
	
	
	public List<OutgoingType> enlist(final OutgoingType...items) {
		List<OutgoingType> results = new ArrayList<OutgoingType>();
		for (OutgoingType item: items) {
			results.add(item);
		}
		return results;
		
	}
	
	protected List<OutgoingType> emptyList() {
		return new ArrayList<OutgoingType>();
	}

}
